

package com.maoshi.shop.distribution.api.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.maoshi.shop.common.util.PageParam;
import com.maoshi.shop.distribution.comment.dto.DistributionMsgDto;
import com.maoshi.shop.distribution.comment.model.DistributionMsg;
import com.maoshi.shop.distribution.comment.service.DistributionMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分销公告接口
 */
@RestController
@RequestMapping("/p/distribution/msg")
@Api(tags = "分销公告接口")
@AllArgsConstructor
public class DistributionMsgController {

    private final DistributionMsgService distributionMsgService;

    @GetMapping("/info")
    @ApiOperation(value = "获取公告详情", notes = "根据公告id获取")
    public ResponseEntity<DistributionMsgDto> info(Long msgId){
        return ResponseEntity.ok(distributionMsgService.getDistributionMsgDtoByMsgId(msgId));
    }

    /**
     * 公告
     */
    @GetMapping("/page")
    @ApiOperation(value = "公告列表", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isTop", value = "是否置顶", required = false, dataType = "Integer")
    })
    public ResponseEntity<IPage<DistributionMsgDto>> page(PageParam<DistributionMsg> page,@RequestParam(value = "isTop", required = false) Integer isTop) {
        return ResponseEntity.ok(distributionMsgService.getDistributionMsgDtoShopId(page,isTop));
    }

}
